<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <!-- 注意 vue-resource 依赖于Vue 所以先后顺序不能反 -->
    <!-- this.$http.jsonp -->
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script src="https://cdn.bootcss.com/vue-resource/1.5.1/vue-resource.js"></script>
    <link href="https://cdn.bootcss.com/animate.css/3.7.2/animate.min.css" rel="stylesheet">
    <!--1. 入场bounceInRight 2.bounceOutLeft离场 -->
</head>

<body>
    <div id="app">
        <input type="button" value="toggle" @click="flag=!flag">
        <!-- 需求：点击按钮，让h3显示，再点击，让h3隐藏 -->
        <!-- 1.使用 transition元素，把需要被动画控制的元素，包裹起来 -->
        <!-- transition 元素，是Vue官方提供的 -->
        <!-- <transition enter-active-class="animated bounceInRight" leave-active-class="animated bounceOutLeft">
            <h3 v-if="flag">这是一个h3</h3>
        </transition> -->
        <!-- 使用 :duration 来统一设置 入场和离场 时候的动画时长；给h3标签使用class来设置动画类 -->
        <!-- <transition enter-active-class="bounceInRight" leave-active-class="bounceOutLeft" :duration="200">
            <h3 v-if="flag" class="animated">这是一个h3</h3>
        </transition> -->
        <!-- 使用 :duration="{enter:200,leave:400}" 来分别设置入场和离场时间-->
        <transition enter-active-class="bounceInRight" leave-active-class="bounceOutLeft" :duration="{enter:200,leave:400}">
                <h3 v-if="flag" class="animated">这是一个h3</h3>
            </transition>
        <hr>

    </div>

    <script>
        var vm = new Vue({
            el: '#app',
            data: {
                flag: false,
                flag2: false
            },
            methods: {}
        })
    </script>
</body>

</html>